package com.itheima.service.cargo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.cargo.FactoryProductDao;
import com.itheima.domain.cargo.FactoryProduct;
import com.itheima.domain.cargo.FactoryProductExample;
import com.itheima.service.cargo.FactoryProductService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 *
 */
@Service
public class FactoryProductServiceImpl implements FactoryProductService {

    @Autowired
    private FactoryProductDao factoryProductDao;

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, FactoryProductExample factoryProductExample) {
        PageHelper.startPage(pageNum, pageSize);
        List<FactoryProduct> list = factoryProductDao.selectByExample(factoryProductExample);
        return  new PageInfo(list, 10);
    }

    @Override
    public FactoryProduct findById(String id) {
        return factoryProductDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(FactoryProduct factoryProduct) {
        factoryProductDao.insertSelective(factoryProduct);
    }

    @Override
    public void update(FactoryProduct factoryProduct) {
        factoryProductDao.updateByPrimaryKeySelective(factoryProduct);
    }

    @Override
    public void delete(String id) {
        factoryProductDao.deleteByPrimaryKey(id);
    }

    @Override
    public void findAll(FactoryProductExample factoryProductExample) {
        factoryProductDao.selectByExample(factoryProductExample);
    }

}
